package seqlist.leetcode;
// 判断链表是否带环
public class Num141 {
    public boolean hasCycle(ListNode head) {
        ListNode fast = head,low = head;
        while (fast != null && fast.next != null) {
            fast = fast.next.next;
            low = low.next;
            // 此时fast和low同时指向相同节点
            if (fast == low) {
                return true;
            }
        }
        // 此时fast或者fast.next == null,直线结构
        return false;
    }
}
